package socket;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Soc {


        public static void main(String[] args) throws IOException {
            Socket soc=null;
            OutputStream os=null;
            Scanner std=new Scanner(System.in);
            try {
                soc=new Socket("192.168.0.198",8888);//建立连接
                System.out.println("ok");
                os=soc.getOutputStream();//获得输出流
                os.write("Welcome to socket programming".getBytes());
                int s=std.nextInt();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                if (soc!=null)
                    try {
                        soc.close();
                    }catch (IOException e){
                        if (os!=null)
                        {os.close();}
                    }
            }

        }

    }

